package com.ruoyi.jpmf.controller.go;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.jpmf.domain.common.Projectinfo;
import com.ruoyi.jpmf.service.DemoService;
import com.ruoyi.jpmf.service.Projectservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @author ruoyi
 * 测试
 */
@Controller
@RequestMapping("/go")
public class GoController extends BaseController {

    @Autowired
    DemoService demoService;

    @Autowired
    Projectservice projectservice;

    private String prefix = "jpmf/demo/go";


    @GetMapping()
    public String go() {
        return prefix + "/go";
    }

    @GetMapping("/add")
    public String add(Model model, HttpServletRequest request) {
        List<Projectinfo> projectinfos = projectservice.findproject(null);
        model.addAttribute("projectinfos",projectinfos);
        return prefix + "/add";
    }

    @GetMapping("/edit")
    public String edit() {
        return prefix + "/edit";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map map) {
        startPage();
        return getDataTable(demoService.findData(map));
    }
}
